-- memberMin and memberMax are actually membernumbers, as is currentstate
property goingDown -- TRUE if going through the list in reverse order
-- FALSE if traversing the list normally
property CurrentState
property NumStates
property name
on CycleState me, name
if name = the name of me then
bumpstate_intern me
end if
end
on SetState me, statenum
if the enabled of me then
if statenum > the numstates of me then
set statenum = the numstates of me
else if statenum < 1 then
set statenum = 1
end if
set the member of sprite the spritenum of me = ¼
member ( the membermin of me + statenum - 1 ) of castLib imageCastLib
end if
end
on setGoingDown me, value
set the goingDown of me to value
end
on SetCycleStyle me, value
set the CycleStyle of me to value
end
---
on bumpstate_intern me
if the enabled of me then
if ( the CycleStyle of me = #Repeat ) then
if NOT the goingDown of me then -- going Up
set curr = the currentstate of me + 1
if curr > the numstates of me then
set curr = 1
end if
else -- going Down
set curr = the currentstate of me - 1
if curr < 1 then set curr = the numstates of me
end if
else -- Reverse cycle
if NOT the goingDown of me then -- going Up
set curr = the currentstate of me + 1
if curr > the numstates of me then
set curr = curr - 2
set the goingDown of me = TRUE
end if
else -- going Down
set curr = the currentstate of me - 1
if curr < 1 then
set curr = 2
set the goingDown of me = FALSE
end if
end if
end if
set the currentstate of me = curr
setstate me, curr
end if
end
on BeginSprite me
set the enabled of me = TRUE
set the membermin of me = the membernum of member memberRefMin
set the membermax of me = the membernum of member memberRefMax
set the numstates of me = (the membermax of me) - (the membermin of me) + 1
set the currentState of me = ( the memberNum of sprite the spriteNum of me ) - ¼
the MemberMin of me + 1
set the imageCastLib of me = the number of castLib ¼
( the castLibNum of sprite ( the spriteNum of me ))
setstate me, the currentstate of me
end
on getPropertyDescriptionList
if the currentspritenum = 0 then
set memdefault = 0
else
set memref = the member of sprite the currentspritenum
set castlibnum = the castlibnum of memref
set memdefault = member (the membernum of member memref + 1) of castlib castlibnum
end if
set p_list = [ ¼
#Name: [ #comment: "Item Name:", ¼
#format: #symbol, ¼
#default: #MultiState_1 ], ¼
#MemberRefMin: [ #comment: "First Image:", ¼
#format: #graphic, ¼
#default: memref ], ¼
#MemberRefMax: [ #comment: "Last Image:", ¼
#format: #graphic, ¼
#default: memdefault ], ¼
#CycleStyle: [ #comment: "Cycle Style:", ¼
#format: #symbol, ¼
#range: [ #Repeat, #Reverse ], ¼
#default: #Repeat ], ¼
#GoingDown: [ #comment: "Reverse Order:", ¼
#format: #boolean, ¼
#default: FALSE ] ¼
]
return p_list
end
on getBehaviorDescription
return ¼
"Makes the sprite cycle through a range of cast members when the CycleState message is received." & RETURN & ¼
"PARAMETERS:" & RETURN & ¼
"ò Item Name - (optional) Enter an item name to identify the current sprite so that it can receive a specific message. Do not use spaces. Use the name as an argument for the Message Sprite or Message All Sprites behaviors." & RETURN & ¼
"ò First Image - Enter the name of the first cast member in the cycling range." & RETURN & ¼
"ò Last Image - Enter the name of the last cast member in the cycling range." & RETURN & ¼
"ò Cycle Mode - Choose Repeat to repeat the same sequence. Choose Reverse to cycle back through the sequence in reverse order." & RETURN & ¼
"ò Reverse Order - Turn this option on to proceed from the last to the first image by default." & RETURN & ¼
"MESSAGES:" & RETURN & ¼
"ò CycleState - Switches the sprite's cast member to the next image in the sequence." & RETURN & ¼
"ò SetState state_number - Advances directly to the position in the sequence identified by state_number."